!function ($) {
    const navWomen = $('.navWomen');
    const secNav = $('.bottom>ul li:first-child').nextAll();
    const shade = $('.shade');
    const triangle = $('.triangle');
    const close = $('.close');
    const top = $('.top');
    const hideLogo = $('#hideLogo');
    const search = $('.search');
    const schChose = $('.schChose');
    const cart = $('.cart');
    if(localStorage.getItem('username') && location.href !='login.html'){
        let nameStr = localStorage.getItem('username').slice(0,3)+'****'+localStorage.getItem('username').slice(7,11);
        $('.top >ul li:first-child').html(nameStr);
        $('.top >ul li:nth-child(2)').html('退出').click(function(){
            localStorage.removeItem('username');
            location.href = 'login.html'
        });
    }
    
    if ($(window).scrollTop() >= 200) {
        top.css({ position: 'fixed' });
        hideLogo.css({ opacity: 1 });
    }
    $(window).on('scroll', function () {
        if ($(this).scrollTop() >= 200) {
            top.css({ position: 'fixed',zIndex:50 });
            hideLogo.css({ opacity: 1 });
        } else {
            top.css({ position: 'relative',zIndex:1});
            hideLogo.css({ opacity: 0 });
        }
        if ($(this).scrollTop() >= 100&& $(this).scrollTop()<200) {
            shade.hide();
            top.css({zIndex:50})
            navWomen.css({ opacity: 0, zIndex: -10 });
        }
    })
    secNav.on('click', function () {
        shade.show();
        navWomen.css({ opacity: 1, zIndex: 50,visibility:'visible' });
        triangle.css({ left: 110 * ($(this).index()) })
    })
    shade.on('click', function () {
        $(this).hide();
        navWomen.css({ opacity: 0, zIndex: -1,visibility:'hidden'});

    })
    close.on('click', function () {
        shade.hide();
        navWomen.css({ opacity: 0, zIndex: -1 });
    })
    search.on('focus',function(){
        schChose.show();
    })
    search.on('blur',function(){
        schChose.hide();
    })
    cart.css({cursor:'pointer'})
    
    cart.on('click',function(){
        location.href='./cart.html';
    })
}(jQuery)